import 'package:car_map/page/res/dimens.dart';
import 'package:car_map/page/res/gaps.dart';
import 'package:car_map/page/res/styles.dart';
import 'package:flutter/material.dart';

///安全条例点击确认后才能点击按钮执行操作
class WidgetAgreeButton extends StatefulWidget {

  final VoidCallback callback;
  final String terms;//条款
  final String note;//注释

  const WidgetAgreeButton({Key key, this.callback, this.terms, this.note}) : super(key: key);

  @override
  _widgetAgreeButtonState createState() => _widgetAgreeButtonState();
}

class _widgetAgreeButtonState extends State<WidgetAgreeButton> {
  bool isCheckValue = false;

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      child: Column(
        children: <Widget>[
          CheckboxListTile(
              title: Text('${widget.terms}',style:TextStyles.textGray12,),
              value: isCheckValue,
              onChanged: (value) {
                setState(() {
                  isCheckValue = value;
                });
              }),
          Gaps.vGap10,
          Container(
            margin: EdgeInsets.only(left: 20.0, right: 20.0),
            child: FlatButton(
                onPressed: widget.callback,
                textColor: Colors.white,
                color: isCheckValue?Colors.blue:Colors.black26,
                disabledColor: isCheckValue?Colors.blue[400]:Colors.black12,
                disabledTextColor: isCheckValue?Colors.white:Colors.black26,
                child: Container(
                  width: double.infinity,
                  height: 48.0,
                  alignment: Alignment.center,
                  child: Text(
                    '查询',
                    style: TextStyle(fontSize: Dimens.font_sp18),
                  ),
                )),
          ),
          Gaps.vGap10,
          Container(
            alignment: Alignment.center,
            child: Text(
              '${widget.note}',
              style:TextStyles.textSize12 ,
            ),
          )
        ],
      ),
    );
  }
}
